//程序设计理论与方法

#include <bits/stdc++.h>

using namespace std;
int t[5] = {0};
vector<vector<int>> s;

void get_sequences(vector<int> &a,int n) {
    if (a.size() == n) {
        vector<int> b;
        for (int i = 0; i < a.size(); i++) b.push_back(a[i]);
        s.push_back(b);
        return;
    }
    for (int j = 0; j < n; j++) {
        if (t[j]) continue;
        t[j] = 1;
        a.push_back(j);
        get_sequences(a,n);
        a.pop_back();
        t[j] = 0;
    }


}

int main() {
    string colors[5] = {"red", "white", "blue", "yellow", "green"};
    string countries[5] = {"english", "swede", "danish", "norwegian", "german"};
    string drinks[5] = {"tea", "coffee", "milk", "beer", "water"};
    string smokes[5] = {"PALL MALL", "DUNHILL", "BLENDS", "BLUEMASTER", "PRINCE"};
    string pets[5] = {"dog", "bird", "cat", "fish", "horse"};

    vector<int> a;
    get_sequences(a,5);

    for (int i0 = 0; i0 < s.size(); i0++) {
        if (s[i0][4] != s[i0][1] - 1) continue;
        for (int i1 = 0; i1 < s.size(); i1++) {
            if (s[i1][0] != s[i0][0]) continue;
            if (0 != s[i1][3]) continue;
            if (abs(s[i1][3] - s[i0][2]) != 1) continue;
            for (int i2 = 0; i2 < s.size(); i2++) {
                if (s[i1][2] != s[i2][0]) continue;
                if (s[i0][4] != s[i2][1]) continue;
                if (2 != s[i2][2]) continue;
                for (int i3 = 0; i3 < s.size(); i3++) {
                    if (s[i0][3] != s[i3][1]) continue;
                    if (s[i3][3] != s[i2][3]) continue;
                    if (s[i1][4] != s[i3][4]) continue;
                    if (abs(s[i3][2] - s[i2][4]) != 1) continue;
                    for (int i4 = 0; i4 < s.size(); i4++) {
                        if (

                                s[i1][0] == s[i0][0] &&
                                s[i1][1] == s[i4][0] &&
                                s[i1][2] == s[i2][0] &&
                                s[i0][4] == s[i0][1] - 1 &&
                                s[i0][4] == s[i2][1] &&
                                s[i3][0] == s[i4][1] &&
                                s[i0][3] == s[i3][1] &&
                                2 == s[i2][2] &&
                                0 == s[i1][3] &&
                                abs(s[i3][2] - s[i4][2]) == 1 &&
                                abs(s[i4][4] - s[i3][1]) == 1 &&
                                s[i3][3] == s[i2][3] &&
                                s[i1][4] == s[i3][4] &&
                                abs(s[i1][3] - s[i0][2]) == 1 &&
                                abs(s[i3][2] - s[i2][4]) == 1
                                ) {
                            cout << s[i4][3] << endl;
                        }
                    }
                }
            }
        }
    }
}
